import React, { Component } from 'react';
import moment from 'moment'
import { connect } from 'react-redux'
import { Modal, Form, Input,Select ,DatePicker ,Radio,Button,Row,Col,InputNumber} from 'antd';
import {date2str,replaceStr} from '../../services/common'
const FormItem = Form.Item;
const RadioGroup = Radio.Group;
const Option =Select.Option;

class ContractViewModal extends Component {
  constructor(props) {
    super(props);
    this.state = {
      visible: false,
    };
  }

  cancelHandler=()=>{
    const { onCancel } = this.props;
    this.props.form.resetFields();
    onCancel();
  }
  render() {
    const { children, dispatch,item,roomList,userList,isShowUser,rackList,editDetailHandler,addDetailHandler } = this.props;
    const { getFieldDecorator } = this.props.form;
    const formItemLayout = {
      labelCol: { span: 6 },
      wrapperCol: { span: 16 },
    };
    const buttons=[
        <Button key="back" type="ghost" size="large" onClick={this.cancelHandler}>关闭</Button>,
      ];
    return (
      <span>
        <Modal
            maskClosable= {this.props.maskClosable}
            title={this.props.title}
            visible={this.props.visible}
            onCancel={this.cancelHandler}
            key={this.props.newKey}
            footer={buttons}
          >
          <Form layout='horizontal'>
            <Row>
              <Col span={24}>               
                <FormItem {...formItemLayout}
                  label="合同编号" hasFeedback>
                   {
                    getFieldDecorator('no', {
                      initialValue: item.no,
                    })(<Input readOnly="readonly"/>)
                  }
                  </FormItem>
                  </Col>
                  </Row>
                  <Row>
                  <Col span={24}>
                  <FormItem {...formItemLayout}
                    label="合同名称" hasFeedback>
                    {
                    getFieldDecorator('name', {
                      initialValue: item.name,
                    })(<Input readOnly="readonly" />)
                    }
                  </FormItem>
                  </Col>
                    </Row>
                    <Row>
                    <Col span={24}>
                    <FormItem {...formItemLayout}
                      label="类型" hasFeedback>                     
                        {
                        getFieldDecorator('type', {
                          initialValue:  item.type=='1'?'买卖合同':item.type=='2'?'赠与合同':
                          item.type=='3'?'租赁合同':'借用合同',
                        })(<Input readOnly="readonly" />)
                        }
                      </FormItem>
                      </Col>
                      </Row>
                      <Row>
                      <Col span={24}>
                      <FormItem {...formItemLayout}
                            label="金额" hasFeedback>
                        {
                        getFieldDecorator('amount', {
                          initialValue: item.amount,
                        })(<Input readOnly="readonly" />)
                        }
                      </FormItem>
                      </Col>
                      </Row>
                      <Row>
                      <Col span={24}>
                      <FormItem
                        {...formItemLayout}
                          label="去税合同额"
                          hasFeedback
                        >
                          {
                          getFieldDecorator('taxAmount', {
                            initialValue: item.taxAmount,
                          })(<Input readOnly="readonly" />)
                          }
                        </FormItem>
                        </Col>
                        </Row>
                        <Row>
                        <Col span={24}>
                        <FormItem
                          {...formItemLayout}
                          label="签订日期"
                          >
                          {
                          getFieldDecorator('signingDate', {
                            initialValue: item.signingDate==null?'':date2str(replaceStr(item.signingDate), "yyyy-MM-dd"),
                          })(<Input readOnly="readonly" />)
                          }                       
                      </FormItem>
                      </Col>
                      </Row>
                      <Row>
                      <Col span={24}>
                      <FormItem
                          {...formItemLayout}
                          label="生效日期"
                          >
                          {
                          getFieldDecorator('effectiveDate', {
                            initialValue: item.effectiveDate==null?'':date2str(replaceStr(item.effectiveDate), "yyyy-MM-dd"),
                          })(<Input readOnly="readonly" />)
                          }                  
                          {/* {item.effectiveDate==null?'':date2str(replaceStr(item.effectiveDate), "yyyy-MM-dd")} */}
                      </FormItem>
                      </Col>
                      </Row>
                      <Row>
                      <Col span={24}>
                      <FormItem
                        {...formItemLayout}
                          label="有效期(月)"
                          hasFeedback
                        >
                        {
                          getFieldDecorator('validityPerio', {
                            initialValue: item.validityPerio,
                          })(<Input readOnly="readonly" />)
                        }                           
                        </FormItem>
                        </Col>
                        </Row>
                        <Row>
                        <Col span={24}>
                        <FormItem
                            {...formItemLayout}
                              label="描述"
                              hasFeedback
                            >
                            {
                              getFieldDecorator('describe', {
                                initialValue: item.describe,
                              })(<Input  type="textarea" autosize={{ minRows: 3, maxRows: 3 }} readOnly="readonly"/>)
                            }                                
                        </FormItem>
                        </Col>
                        </Row>
                </Form>
        </Modal>
      </span>
    );
  }

}

export default Form.create()(ContractViewModal)
